package creational.property.simple;

public class Test {

    public static void main(String[] args) {

        //首先提供一个原型的实现类
        AudiCar pAudiCar = new AudiCar();
        Client pClient1 = new Client(pAudiCar);
        //克隆的请求是由客户端发起的
        AudiCar pCopyAudiCar = (AudiCar) pClient1.clone();
        System.out.println("奥迪原型名称:" + pAudiCar.getName());
        System.out.println("奥迪复制名称:" + pCopyAudiCar.getName());
        System.out.println("奥迪原型与复制是否为同一个对象:"+(pAudiCar == pCopyAudiCar));

        HondaCar pHondaCar = new HondaCar();
        Client pClient2 = new Client(pHondaCar);
        HondaCar pCopyHondaCar = (HondaCar) pClient2.clone();
        System.out.println("本田原型名称:" + pHondaCar.getName());
        System.out.println("本田复制名称:" + pCopyHondaCar.getName());
        System.out.println("本田原型与复制是否为同一个对象:"+(pHondaCar == pCopyHondaCar));
    }

}
